package com.example.springboothomework.entity;

import lombok.*;
import org.hibernate.annotations.Comment;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.time.LocalDate;


/**
 * @author: chenjianhao
 * @date: 2025/6/5
 * 员工实体类，用于表示员工信息。
 */
@Getter
@Setter
@Entity
@Table(name = "employee")
public class Employee implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 员工 ID，主键，唯一标识一个员工。
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Comment("员工 ID")
    private Long id;

    /**
     * 员工姓名。
     */
    @Column(length = 100, nullable = false)
    @Comment("员工姓名")
    private String name;

    /**
     * 入职日期。
     */
    @Column(nullable = false)
    @Comment("入职日期")
    private LocalDate employmentDate;

    /**
     * 年龄。
     */
    @Column( nullable = false)
    @Comment("年龄")
    private Integer age;

    /**
     * 是否在职。
     */
    @Column(name = "is_employed", nullable = false)
    @Comment("是否在职")
    private Boolean employed;

    /**
     * 所属公司id。
     */
    @Column(nullable = false)
    @Comment("所属公司id")
    private Long companyId;


    @Override
    public String toString() {
        return "Employee{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", employmentDate=" + employmentDate +
                ", age=" + age +
                ", employed=" + employed +
                ", companyId=" + companyId +
                '}';
    }
}
